package com.yejiali.backend.controller;

import com.yejiali.backend.entity.dto.LoginRequestDTO;
import com.yejiali.backend.response.Response;
import com.yejiali.backend.service.LoginService;
import com.yejiali.backend.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @Author:yejiali
 * @Date:2025/5/14-05-14-14:54
 * @Decsription:com.yejiali.backend.controller
 * @Version:1.0
 */
@RestController
@Tag(name = "登录注册管理", description = "用户登录注册接口")
public class LoginController {
    @Autowired
    private LoginService userService;

    /**
     * 登录
     * @return
     */
    @PostMapping("/login")
    @Operation(summary = "用户登录接口", description = "用户上传用户名密码进行登录")
    public Response login(@Validated @RequestBody LoginRequestDTO requestDTO){
        return userService.login(requestDTO);
    }

    /**
     * 退出登录
     * @return
     */
    @PostMapping("/logout")
    @Operation(summary = "用户登出接口", description = "退出登录")
    public Response logout(){
        return userService.logout();
    }

}
